package com.bigdata.movieticketapi.controller;

import com.bigdata.movieticketapi.common.pojo.PageResult;
import com.bigdata.movieticketapi.entity.Movie;
import com.bigdata.movieticketapi.service.IMovieService;
import com.bigdata.movieticketapi.vo.req.GetDataByIdReqVo;
import com.bigdata.movieticketapi.vo.req.MovieReqVO;
import com.bigdata.movieticketapi.vo.req.PageMovieReqVO;
import com.bigdata.movieticketapi.vo.resp.MovieDetailRespVO;
import com.bigdata.movieticketapi.vo.resp.SelectListRespVO;
import com.bigdata.movieticketapi.vo.resp.PageMovieRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author movie
 * @since 2023-10-26
 */
@RestController
@RequestMapping("/api")
@Api(tags = "电影模块")
public class MovieController {

    @Resource
    private IMovieService iMovieService;

    @PostMapping("/admin/movie/add")
    @ApiOperation(value = "添加影片")
    public void addMovie(@RequestBody @Valid MovieReqVO vo){
        iMovieService.addMovie(vo);
    }

    @PostMapping("/admin/movie/edit")
    @ApiOperation(value = "编辑影片")
    public void updateMovie(@RequestBody @Valid Movie movie){
        iMovieService.updateMovie(movie);
    }

    @PostMapping("/admin/movie")
    @ApiOperation(value = "影片分页接口")
    public PageResult<PageMovieRespVO> pageMovies(@RequestBody @Valid PageMovieReqVO vo){
        return iMovieService.pageMovies(vo);
    }

    @PostMapping("/uniApp/movie")
    @ApiOperation(value = "影片分页接口")
    public PageResult<PageMovieRespVO> uniAppPageMovies(@RequestBody @Valid PageMovieReqVO vo){
        return iMovieService.uniAppPageMovie(vo);
    }

    @PostMapping("/admin/movie/selectList")
    @ApiOperation(value = "电影选择器列表")
    public List<SelectListRespVO> getMovieSelectList(){
        return iMovieService.getMovieSelectList();
    }

    @PostMapping("/uniApp/movie/detail")
    @ApiOperation(value = "影片详情")
    public MovieDetailRespVO getMovieDetail(@RequestBody @Valid GetDataByIdReqVo vo){
        return iMovieService.getMovieDetail(vo);
    }
}
